import logging

class Logger(object):
    def __init__(self, pkg_type : str, path : str):
        self.pkg_type = pkg_type

        self.error_log = logging.getLogger(f"{pkg_type}_error")
        self.info_log = logging.getLogger(f"{pkg_type}")
        formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')

        info_hdlr = logging.FileHandler(f"{path}/{pkg_type}.log")
        err_hdlr = logging.FileHandler(f"{path}/{pkg_type}_error.log")

        info_hdlr.setFormatter(formatter)
        err_hdlr.setFormatter(formatter)

        self.error_log.addHandler(err_hdlr)
        self.error_log.setLevel(logging.ERROR)
        self.info_log.addHandler(info_hdlr)
        self.info_log.setLevel(logging.INFO)

    def info(self, content):
        self.info_log.info(content)

    def success(self, content):
        self.info_log.info(f"[SUCC]: {content}")

    def error(self, content):
        self.error_log.error(content)

    def failed(self, content):
        self.error_log.warn(content)
